Working with WEO data

Stata files of the various WEO database vintages are stored at \\imfdata_Stata_Databases.

We will use the April 2023 database. This is in the file WEOApr2023Pub.dat. We will copy it to a subdirectory “databases”.

To read the file, we first need to load the library haven.

library(haven)
library(dplyr)

Attaching package: 'dplyr'
The following objects are masked from 'package:stats':

    filter, lag
The following objects are masked from 'package:base':

    intersect, setdiff, setequal, union

We now read the WEO database into a variable weo

weo<-read_dta(here::here("databases/WEOApr2023Pub.dta"))

Let’s now explore a subset of the WEO data. Let’s extract WEO data for US and Japan from the years 2019-2025, for three indicators.

usa_japan <- weo %>%
  filter(year > 2019) %>%
  filter(year < 2025) %>%
  filter(ifscode %in% c(111, 158)) %>%
  select(country, ifscode, year, ngdp_r, lur, bca_gdp_bp6)

Now let’s take a closer look at how the data is structured and stacked.

usa_japan
# A tibble: 10 × 6
   country       ifscode  year  ngdp_r   lur bca_gdp_bp6
   <chr>           <dbl> <dbl>   <dbl> <dbl>       <dbl>
 1 United States     111  2020  18509.  8.09       -2.94
 2 United States     111  2021  19610.  5.37       -3.63
 3 United States     111  2022  20015.  3.64       -3.63
 4 United States     111  2023  20331.  3.83       -2.71
 5 United States     111  2024  20547.  4.92       -2.49
 6 Japan             158  2020 528894.  2.78        2.93
 7 Japan             158  2021 540237.  2.82        3.94
 8 Japan             158  2022 546045.  2.56        2.13
 9 Japan             158  2023 553157.  2.3         2.99
10 Japan             158  2024 558792.  2.3         3.98

The dataset is in a stacked format, meaning that each row represents a unique combination of country, year, and associated indicators (ngdp_r, lur, bca_gdp_bp6).

This structure is advantageous for time-series and panel data analysis, as it allows us to easily filter, group, and summarize data by country or year.

This tutorial provides you with a foundation for working with WEO data, enabling basic extraction, exploration, and preparation for deeper analysis or visualization.